Skip to content

fix(autocomplete): omit hidden flags from suggestions - #122

Merged
saioai merged 2 commits into
openai:mainfrom
sylvesterkaczmarek:fix/autocomplete-hidden-flags
Sep 14, 2026
Merged

saioai merged 2 commits into
openai:mainfrom
sylvesterkaczmarek:fix/autocomplete-hidden-flags

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Summary

Keep hidden/internal CLI flags out of shell-completion suggestions.

Problem

The autocomplete code already respects cli.VisibleFlag when resolving an entered flag through findFlag, but the flag-name completion path loops over every flag in cmd.Flags without applying the same visibility check.

That means flags deliberately marked hidden can still be surfaced by Bash/Zsh/Fish/PowerShell completion when the user starts typing - or --.

This is separate from the existing hidden-command work: command suggestions already have their own child.Hidden handling, while this PR fixes flag visibility.

Fix

Apply the same cli.VisibleFlag / IsVisible() guard used by findFlag before generating flag-name completions.

Visible flags and aliases keep their existing completion behavior. Flags that do not implement cli.VisibleFlag are also unchanged.

Regression coverage

Added a focused synthetic-command regression with one visible and one hidden flag, each with a short alias. The test verifies both long and short visible names remain suggested while both hidden names are omitted.

Validation

The branch is based directly on current upstream main (a7719136b8ed401b0c51a05553a5e4f720150307) and contains one DCO-signed commit. The production change is 3 lines in handwritten internal/autocomplete/autocomplete.go, plus focused regression coverage. Full repository test execution is left to CI.

Risk

Low. The change only removes completion candidates for flags the CLI already marks as not visible; parsing and command execution are unchanged.

Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
@sylvesterkaczmarek
sylvesterkaczmarek requested a review from a team as a code owner August 20, 2026 21:30
@markstuart-oai

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-14T20:34:35.748666Z ca2516e New commits
🔒 Security Review Completed 2026-09-14T20:36:07.696400Z ca2516e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 7aba6a28ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 7aba6a28ee

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@github-actions

Copy link
Copy Markdown

Castiron custom code

✅ No new custom-code files detected.

5 mixed files remain; 0 existing customizations changed.

Compared 642d5119227bca2516e7baf3. Generated baselines verified.

5 existing customizations unchanged
  • pkg/cmd/adminorganizationcertificate.go
  • pkg/cmd/cmd.go
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_report.py

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 34893689033 --repo openai/openai-cli \
  --name castiron-custom-code-34893689033-1 --dir /tmp/castiron-custom-code-34893689033-1
git apply --stat /tmp/castiron-custom-code-34893689033-1/custom-code.patch
cat /tmp/castiron-custom-code-34893689033-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin 642d5119227b54a84de0b0aa38d99d148a51148c ca2516e7baf3dcd284f9b4e2f7212daa9abd8616
python3 scripts/castiron/custom_code_report.py report \
  --base 642d5119227b54a84de0b0aa38d99d148a51148c \
  --head ca2516e7baf3dcd284f9b4e2f7212daa9abd8616 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-ca2516e7baf3
cat /tmp/castiron-custom-code-ca2516e7baf3/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

@saioai saioai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hidden flags and their aliases no longer show up in autocomplete, but the flags still work if typed directly. the new test caught the issue on main and passed 100 runs on this branch. race tests, internal tests, build, and vet passed locally too. the full suite passed with one FIFO test excluded because it also fails on main. looks good

@saioai
saioai enabled auto-merge September 14, 2026 21:42
@saioai
saioai added this pull request to the merge queue Sep 14, 2026
Merged via the queue into openai:main with commit 137d59b Sep 14, 2026
11 checks passed
@openai-sdks openai-sdks Bot mentioned this pull request Sep 14, 2026
@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review and validation. Glad the hidden-flag behavior and aliases are now covered and this is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants